import java.util.LinkedList;
import java.util.ListIterator;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2024-05-16
 * Time: 17:44
 */
public class Test {
    public static void main(String[] args) {
        MyQueue myQueue = new MyQueue();
        myQueue.offer(1);
        myQueue.offer(2);
        myQueue.offer(3);
        System.out.println(myQueue.peek());
        System.out.println(myQueue.peek());
        System.out.println(myQueue.peek());
        System.out.println(myQueue.poll());
        System.out.println(myQueue.poll());
        System.out.println(myQueue.poll());
        System.out.println(myQueue.poll());
        System.out.println(myQueue.peek());
        myQueue.offer(1);
        System.out.println(myQueue.poll());
        System.out.println("===================");
        System.out.println(myQueue.poll());
    }
    public static void main3(String[] args) {
        MyStack stack = new MyStack();
        stack.push(1);
        stack.push(2);
        stack.push(3);
        stack.push(4);
        System.out.println(stack.pop());
        System.out.println(stack.pop());
        System.out.println(stack.pop());
        System.out.println(stack.pop());
        System.out.println(stack.pop());
//        System.out.println(stack.peek());
//        System.out.println(stack.peek());
//        System.out.println(stack.peek());
//        System.out.println(stack.peek());
//        System.out.println(stack.peek());
//        System.out.println(stack.peek());

    }
    public static void main1(String[] args) {
        LinkedList<Integer> list = new LinkedList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);
        /**
         * 打印方法总结
         */
        //1
        System.out.println(list);
        //2.for循环
        for (int i = 0; i < list.size(); i++) {
            System.out.print(list.get(i)+" ");
        }
        System.out.println();
        //3.1 迭代器
        ListIterator<Integer> it = list.listIterator();
        while(it.hasNext()){
            System.out.print(it.next()+" ");
        }
        System.out.println();
        //3.2 逆序打印
        ListIterator<Integer> it2 = list.listIterator(list.size());
        while(it2.hasPrevious()){
            System.out.print(it2.previous()+" ");
        }
        System.out.println();
        //4 foreach
        for (int x :  list ) {
            System.out.print(x+" ");
        }
    }
    public static void main2(String[] args) {
        MyLinkedList list = new MyLinkedList();
        list.addFirst(1);
        list.addFirst(2);
        list.addFirst(3);
        list.addFirst(4);
        list.display();
        System.out.println("==========");
        list.addLast(5);
        list.addLast(6);
        list.addLast(7);
        list.addLast(8);
        list.display();

        System.out.println("====================");
        System.out.println(list.contains(1));
        System.out.println(list.contains(4));
        System.out.println(list.contains(8));
        System.out.println(list.contains(10));
        System.out.println(list.size());
        System.out.println("=================");
        list.addIndex(0,11);
        list.display();
        list.addIndex(list.size(),22);
        list.display();
        list.addIndex(2,33);
        list.display();
        list.remove(11);
        list.display();
        System.out.println("=================");
        list.remove(22);
        list.display();
        System.out.println("=================");
        list.remove(2);
        list.display();
        System.out.println("=================");
        list.remove(22);
        list.display();
        list.clear();
        list.addFirst(1);
        list.addFirst(1);
        list.addFirst(1);
        list.addFirst(1);
        list.addFirst(2);
        list.addFirst(3);
        list.addFirst(1);
        list.addFirst(34);
        list.addFirst(1);
        System.out.println("==================");
   list.display();
        list.remove(1);
        list.display();
list.removeAllKey(1);
        System.out.println("=====");
list.display();

    }

}
